var N,i,j:integer;
    A:array[1..100000] of integer;
    S,S1:longint;
    x:integer;
begin
  readln(N);
  S:=0;
  for i:=1 to N do
    begin
      read(A[i]);
      S:=S+A[i];
    end;
  for i:=1 to N-1 do
    for j:=1 to N-i do
      if A[j]<A[j+1] then
                       begin
                         x:=A[j];
                         A[j]:=A[j+1];
                         A[j+1]:=x;
                       end;
  S1:=0;
  for i:=1 to N div 2 do
    S1:=S1+A[i];
  write(2*S1-S);
  end.
